<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
    用户名：<input type="text" id="username">
    密码：<input type="password" id="password">
    <button id="btn">提交</button>
    <button id="btn2">获取数据</button> 
    <!-- http://172.18.50.2:3000/getDateBase -->

    <script>
        let btn = document.getElementById("btn");
        let username = document.getElementById("username");
        let password = document.getElementById("password");

        let btn2 = document.getElementById("btn2");

        btn.onclick = function(){
            axios({
                method:"post",
                url:"http://172.18.50.2:3000/findUser",
                data:{
                    username:username.value,
                    password:password.value
                }
            })
            .then(res => {
                console.log("返回的结果",res);
            })
        }

        btn2.onclick = function(){
            // axios默认请求方法：GET
            // axios默认的请求头类型：application/json
            axios({
                url:"http://localhost:3000/getDateBase"
            })
            .then(res => {
                console.log(res);
                console.log(res.data);
            })
        }
    </script>
</body>
</html>